{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "def yanghui(t):\n",
    "    print([1])#输出第一行\n",
    "    line = [1, 1]\n",
    "    print(line)#输出第二行\n",
    "    for i in range(2, t):\n",
    "        r = []#存储当前行除两端之外的数字\n",
    "        for j in range(0,len(line)-1):\n",
    "            r.append(line[j] + line[j+1])#第i行除两端之外其他的数字\n",
    "        line = [1] + r + [1]#第i行的全部数字\n",
    "        print(line)#输出第i行"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
